#！/bin/bash
source /etc/profile
if [ -n "$1" ]
then
  do_date=$1
else
  do_date=`date -d "-1 day" +%F`
fi
sql="
insert overwrite table lagou_shops_his
select shopid, shopname, status, createtime, modifytime, start_date,  end_date
from lagou_shops_his where end_date < '$do_date'

union all

select shopid, shopname, status, createtime, modifytime, start_date,
'9999-12-31' end_date
from lagou_shops_his where start_date <= '$do_date' and end_date >= '$do_date'
"
hive -e "$sql"